<template>
    <!-- 租赁房产管理 -->
    <base-breadcrumb :title="$route.meta.title">
        <a-row :gutter="10" class="page-height">
            <!-- 树搜索 -->
            <a-col :span="6">
                <a-card class="page-height-tree">
                    <title-name title="工会组织"></title-name>
                    <!-- 公司组织树搜索 -->
                    <tree-union
                        ref="treeOrganization"
                        @loader="getTable"
                        :expandByAuto="true"
                        :selectOptions.sync="selectOptions"
                        :showChildWithSearch="true"
                    />
                </a-card>
            </a-col>
            <a-col :span="18" class="page-height-list-wrapper">
                <!-- 搜索 -->
                <searchData :searchData="searchArr" @search="search"></searchData>
                <!-- 表格 -->

                <a-card :bordered="false"  class="page-height-list">
                    <!-- <title-name title="组织信息列表"></title-name> -->
                    <!-- <a-button class="mb12" icon="plus" type="primary" @click="handleManage(2)">新增</a-button> -->
                    <!-- 表格 -->
                    <list-table
                        ref="table"
                        tableLayout="fixed"
                        size="default"
                        rowKey="userId"
                        :columns="columns"
                        :request="loadData"
                        :alert="true"
                        show-size-changer
                        show-quick-jumper
                        showPagination="auto"
                    >
                        <span slot="auditStatus" slot-scope="text, record">
                            <list-status
                                :status="record.auditStatus"
                                :isApproval="true"
                                conversion="en"
                                :text="text"
                            ></list-status>
                        </span>
                        <template slot="action" slot-scope="text, record">
                            <a @click="handleManage(0, record)" v-btnPermission="'lu_002_loo_04'">查看</a>
                            <!-- <a-divider type="vertical" v-btnPermission="'lu_002_edi_02'"></a-divider>
                            <a @click="handleManage(1, record)" v-btnPermission="'lu_002_edi_02'">编辑</a> -->
                            <!-- 删除 -->
                            <!-- <a-divider v-if="record.id != 1" type="vertical"></a-divider>
                            <a class="del_btn" v-if="record.id != 1" @click="handleRemoves([record.id])">删除</a> -->
                        </template>
                    </list-table>
                </a-card>
            </a-col>
        </a-row>
    </base-breadcrumb>
</template>

<script>
import { STable } from '@/components' // 表格
import { getPageUnionEmployeeList, deleteByPrimaryKey } from '@/api/union/organizationManagement' // api
import TreeSelectOrganization from '@/components/TreeSelectOrganization'
import Selector from '@/components/Select/Selector'
import BasePage from '@/views/basePage' // 基础配置
import SelectHierarchy from '@/components/Select/SelectHierarchy'
import TreeUnion from '@/components/businessComponents/TreeUnion' // 树
import SelectCompanyAndProject from '@/components/Select/SelectCompanyAndProject'
const searchArr = [
    // 搜索框
    {
        name: '会员',
        type: 'input',
        value: 'name',
    },
    // {
    //     name: '所属层级',
    //     valueKey: 'unionLevelId',
    //     type: Selector,
    //     selectType: '1',
    //     urlType: 'union',
    // },

    // {
    //     name: '单位',
    //     valueKey: 'orgId',
    //     type: SelectCompanyAndProject,
    // },
    {
        name: '工会职务',
        valueKey: 'unionPost',
        type: Selector,
        urlType: 'union',
        isGroup: true,
        apiSuffix: 'queryUnionPost',
    },
]
const columns = [
    {
        title: '序号',
        width: 80,
        dataIndex: 'index',
        customRender() {
            return arguments[2] + 1
        },
    },
    {
        title: '会员',

        dataIndex: 'name',
    },
    {
        title: '工会组织',
        ellipsis: true,
        dataIndex: 'unionOrgStr',
    },
    {
        title: '单位',
        ellipsis: true,
        dataIndex: 'orgStr',
    },
    {
        title: '工会职务',
        ellipsis: true,
        dataIndex: 'unionPostStr',
    },

    {
        title: '操作',
        dataIndex: 'action',
        width: '180px',
        align: 'center',
        scopedSlots: { customRender: 'action' },
    },
]
export default {
    name:'a'+Date.now(),
    extends: new BasePage(),
    components: {
        STable,
        TreeUnion,
    },
    data() {
        this.columns = columns
        this.searchArr = searchArr
        return {
            queryParam: {}, // 查询参数
            selectOptions: {}, // 选中节点对象
            loadData: (parameter) => {
                const requestParameters = Object.assign({}, parameter, { query: this.queryParam })
                return getPageUnionEmployeeList(requestParameters).then((res) => {
                    console.log(res)
                    return res
                })
            }, // 加载数据方法 必须为 Promise 对象
            removeApi: { remove: deleteByPrimaryKey }, // api

            form: {},
        }
    },
    mounted() {
        this.$refs.treeOrganization.getList().then((res) => {
            this.$refs.table.refresh(true)
        })
    },
    methods: {
        // 搜索
        search(value) {
            value && (this.queryParam = value)
            this.queryParam.unionOrgId = this.selectOptions.id || void 0
            this.$refs.table.refresh(true)
        },
        getTable(value) {
            this.queryParam.unionOrgId = this.selectOptions.id
            // this.queryParam.parentId = this.selectOptions.id
            this.$refs.table.refresh(true)
        },
        // 操作栏
        handleManage(type, record) {
            this.editModel = type
            console.log(record)
            let query = {
                editModel: type,
            }
            if (record && record.userId) {
                query.id = record.userId
            }
            this.$router.push({
                name: '/union/organizationManagement/vipManagement/updateVipManagement',
                query,
            })
        },
    },
}
</script>
